package com.pingancar.creditmanage.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.lang.reflect.Field;

/**
 * Created by SilverStone-WW on 2015/3/4.
 */
public class LBSMessage {
    final private String ak = "wFPFZHW4pchcuUGeLxGgWwq4";
    final private String geotable_id = "95394";

    private Integer id;
    private String title;
    private String tags;
    private Double latitude;
    private Double longitude;
    private Integer coord_type;
    private String address;
    private Integer shopid;
    private String city;
    private String create_time;
    private String district;
    private Double[] location;
    private String modify_time;
    private String province;
    private Integer city_id;
    private Integer uid;
    private Integer distance;
    private Integer weight;

    public String getAk() {
        return ak;
    }

    public String getGeotable_id() {
        return geotable_id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTags() {
        return tags;
    }

    public void setTags(String tags) {
        this.tags = tags;
    }

    public Double getLatitude() {
        return latitude;
    }

    public void setLatitude(Double latitude) {
        this.latitude = latitude;
    }

    public Double getLongitude() {
        return longitude;
    }

    public void setLongitude(Double longitude) {
        this.longitude = longitude;
    }

    public Integer getCoord_type() {
        return coord_type;
    }

    public void setCoord_type(Integer coord_type) {
        this.coord_type = coord_type;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Integer getShopid() {
        return shopid;
    }

    public void setShopid(Integer shopid) {
        this.shopid = shopid;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCreate_time() {
        return create_time;
    }

    public void setCreate_time(String create_time) {
        this.create_time = create_time;
    }

    public String getDistrict() {
        return district;
    }

    public void setDistrict(String district) {
        this.district = district;
    }

    public Double[] getLocation() {
        return location;
    }

    public void setLocation(Double[] location) {
        this.location = location;
    }

    public String getModify_time() {
        return modify_time;
    }

    public void setModify_time(String modify_time) {
        this.modify_time = modify_time;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public Integer getCity_id() {
        return city_id;
    }

    public void setCity_id(Integer city_id) {
        this.city_id = city_id;
    }

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    public Integer getDistance() {
        return distance;
    }

    public void setDistance(Integer distance) {
        this.distance = distance;
    }

    public Integer getWeight() {
        return weight;
    }

    public void setWeight(Integer weight) {
        this.weight = weight;
    }

    public String toJson() {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            return objectMapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            return null;
        }
    }

    public String toForm() {
        StringBuilder stringBuilder = new StringBuilder();
        boolean first = true;
        for (Field f : this.getClass().getDeclaredFields()) {
            try {
                Object o = f.get(this);
                if (o == null)
                    continue;
                if (first) {
                    first = false;
                } else {
                    stringBuilder.append("&");
                }
                stringBuilder.append(f.getName()).append("=").append(o);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }

        String str = stringBuilder.toString();
        return str;
    }
}
